# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Jick Nan <jick.nan@gmail.com>

pkgname=uucp
pkgver=1.07
pkgrel=7
pkgdesc="Taylor UUCP is a free implementation of UUCP and is the standard UUCP used on the GNU system"
arch=(loong64 x86_64)
url="https://www.gnu.org/software/uucp/uucp.html"
license=('GPL')
makedepends=('wget' 'sed' 'grep')
backup=('etc/uucp/config'
	'etc/uucp/port'
	'etc/uucp/sys')
source=(https://ftp.gnu.org/gnu/uucp/${pkgname}-${pkgver}.tar.gz)
sha256sums=('060c15bfba6cfd1171ad81f782789032113e199a5aded8f8e0c1c5bd1385b62c')

prepare() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  sed -i 's|${CC-cc} -E|${CC-cc} -E -O2|g' configure
}

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  ./configure --prefix=/usr --mandir=/usr/share/man --with-newconfigdir=/etc/uucp --sbindir=/usr/bin
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install

  install -D -m644 sample/config "$pkgdir"/etc/uucp/config
  install -D -m644 sample/sys1 "$pkgdir"/etc/uucp/sys
  install -D -m644 sample/port "$pkgdir"/etc/uucp/port
  mv "$pkgdir"/usr/info "$pkgdir"/usr/share/

  sed -i 's|\$\*|"$@"|' "$pkgdir"/usr/bin/{uuto,uusched}
  chmod u+w "$pkgdir"/usr/bin/*
}
